package cn.csc.module.member.dal.mysql.area;

import java.util.*;

import cn.csc.framework.common.pojo.PageResult;
import cn.csc.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.csc.framework.mybatis.core.mapper.BaseMapperX;
import cn.csc.module.member.dal.dataobject.area.AreaDO;
import org.apache.ibatis.annotations.Mapper;
import cn.csc.module.member.controller.admin.area.vo.*;

/**
 * 省市区地区信息 Mapper
 *
 * @author liuchuang
 */
@Mapper
public interface AreaMapper extends BaseMapperX<AreaDO> {

    default PageResult<AreaDO> selectPage(AreaPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<AreaDO>()
                .betweenIfPresent(AreaDO::getCreateTime, reqVO.getCreateTime())
                .likeIfPresent(AreaDO::getAreaName, reqVO.getAreaName())
                .eqIfPresent(AreaDO::getParentId, reqVO.getParentId())
                .eqIfPresent(AreaDO::getLevel, reqVO.getLevel())
                .orderByDesc(AreaDO::getId));
    }

    default List<AreaDO> selectList(AreaExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<AreaDO>()
                .betweenIfPresent(AreaDO::getCreateTime, reqVO.getCreateTime())
                .likeIfPresent(AreaDO::getAreaName, reqVO.getAreaName())
                .eqIfPresent(AreaDO::getParentId, reqVO.getParentId())
                .eqIfPresent(AreaDO::getLevel, reqVO.getLevel())
                .orderByDesc(AreaDO::getId));
    }

}
